function AI(Monster, AI)
{
  if (Monster == "Monster1")
  {
    if (AI == "Standard")
    {
      if (Math.random() <= Monster1.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster1Attack();
      }
    }
    else if (AI == "SP4WhenLow")
    {
      if (Monster1.hp <= Monster1.maxhp/4)
      {
      LoadMonsterStats();
      MonsterSpecial4();      
      }
      else if (Math.random() <= Monster1.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster1Attack();
      }
    }
  }
  else if (Monster == "Monster2")
  {
    if (AI == "Standard")
    {
      if (Math.random() <= Monster2.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster2Attack();
      }
    }
    else if (AI == "SP4WhenLow")
    {
      if (Monster2.hp <= Monster2.maxhp/4)
      {
      LoadMonsterStats();
      MonsterSpecial4();      
      }
      else if (Math.random() <= Monster2.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster2Attack();
      }
    }
  }
  else if (Monster == "Monster3")
  {
    if (AI == "Standard")
    {
      if (Math.random() <= Monster3.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster3Attack();
      }
    }
    else if (AI == "SP4WhenLow")
    {
      if (Monster3.hp <= Monster3.maxhp/4)
      {
      LoadMonsterStats();
      MonsterSpecial4();      
      }
      else if (Math.random() <= Monster3.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster3Attack();
      }
    }
  }
  else if (Monster == "Monster4")
  {
    if (AI == "Standard")
    {
      if (Math.random() <= Monster4.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster4Attack();
      }
    }
    else if (AI == "SP4WhenLow")
    {
      if (Monster4.hp <= Monster4.maxhp/4)
      {
      LoadMonsterStats();
      MonsterSpecial4();      
      }
      else if (Math.random() <= Monster4.specialchance)
      {
      MonsterSpecial();
      }
      else
      {
      Monster4Attack();
      }
    }
  }
}